# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=muse
pkgver=4.1.0
pkgrel=3
pkgdesc="A digital audio workstation with support for both Audio and MIDI"
arch=(loong64 x86_64)
url="https://github.com/muse-sequencer/muse"
license=(GPL2)
groups=(pro-audio)
depends=(
  gcc-libs
  glibc
  hicolor-icon-theme
  python
  python-pyqt5
  python-pyro
  python-six
  qt5-base
  qt5-svg
)
makedepends=(
  alsa-lib
  cmake
  dssi
  fluidsynth
  glib2
  jack
  ladspa
  liblo
  liblrdf
  libsamplerate
  libsndfile
  lilv
  lv2
  qt5-tools
  rtaudio
  rubberband
)
provides=(
  dssi-host
  ladspa-host
  lv2-host
  vst-host
)
source=($url/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('6a343fab0aff1a6035dacc3d484cbe2fa19bc8391a66d749d5de156e156db9964a56890a0c412f7d04856645796b7676c577f8e8a240636354a743cb149ca651')
b2sums=('f8d1d0b70152939dd9a9f5fb391074f364b315911a5fb0d66d76e1f98c1d21bad2857334217782711ca22821b8272be5195454b706309dcfb96324d769a454ba')

prepare() {
  # rename MusE-INSTALL_NAME to muse, because this reflects the package name
  sed -e 's/muse-4.1/muse/g' -i $pkgname-$pkgver/src/CMakeLists.txt
}

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -D ENABLE_PYTHON=ON
    -D ENABLE_LV2_GTK2=OFF
    -S $pkgname-$pkgver/src
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  depends+=(
    alsa-lib libasound.so
    fluidsynth libfluidsynth.so
    glib2 libglib-2.0.so libgobject-2.0.so
    libinstpatch libinstpatch-1.0.so
    jack libjack.so
    lilv liblilv-0.so
    liblo liblo.so
    liblrdf liblrdf.so
    rtaudio librtaudio.so
    rubberband librubberband.so
    libsamplerate libsamplerate.so
    libsndfile libsndfile.so
  )

  DESTDIR="$pkgdir" cmake --install build
}
